//
//  ResultInfoTitleCell.m
//  iiecg
//
//  Created by Shanlin on 2017/3/1.
//  Copyright © 2017年 Boundary Technology. All rights reserved.
//

#import "ResultInfoTitleCell.h"

@interface ResultInfoTitleCell ()

@property (weak, nonatomic) IBOutlet UIImageView *titleImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelH;
@property (nonatomic,strong) ResultInfoTitleBean* bean;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageH;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageW;

@end

@implementation ResultInfoTitleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
//    self.titleLabel.font = FONT_LABEL_SIZE(scale(17));
    self.titleLabel.font = [UIFont systemFontOfSize:17];
    self.labelH.constant = scale(21);
    self.imageW.constant = scale(44);
    self.imageH.constant = scale(44);
}

-(void)setBean:(ResultInfoTitleBean *)bean
{
    __weak typeof(self)weakSelf = self;
    _bean = bean;
    if (!bean) {
        return;
    }
    [IKPublicUtil runOnMainThread:^{
        weakSelf.titleImageView.image = [UIImage imageNamed:bean.titleImageName];
        weakSelf.titleLabel.textColor = COLOR_BLACK_LIGHT;
        weakSelf.titleLabel.text = bean.title;
        
    }];
}


+(instancetype)createWith:(UITableView *)tableView bean:(ResultInfoTitleBean *)bean{
    static NSString *ID = @"ResultInfoTitleCell";
    ResultInfoTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:ID owner:nil options:nil] lastObject];
    } else {
        while ([cell.contentView.subviews lastObject] != nil) {
            [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
        }
    }
    cell.bean = bean;
    return cell;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
